home *** CD-ROM | disk | FTP | other *** search
- INTRO_LIBM(3M) Last changed: 1-6-98
-
-
- NNAAMMEE
- IINNTTRROO__LLIIBBMM - Introduction to math library routines
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- See individual man pages for implementation details
-
- DDEESSCCRRIIPPTTIIOONN
- The math routines are listed with the other intrinsic procedures in
- alphabetical order, usually by generic function name. Generic
- function names are function calls that cause the compiler to compile
- automatically the appropriate data type version of a routine, based on
- the type of the input data. For example, a call to the generic
- function LLOOGG with a type of input data of complex compiles as CCLLOOGG.
-
- In general, on UNICOS systems, real functions have no prefix; integer
- functions are prefixed with I, double precision functions are prefixed
- with D, complex functions are prefixed with C, and double precision
- complex functions are prefixed with CD (for example, AABBSS, IIAABBSS, DDAABBSS,
- CCAABBSS, and CCDDAABBSS). Functions with a type different from their
- arguments are noted. Real functions are usually the same as the
- generic function name.
-
- On UNICOS/mk systems, two precisions are provided for real data:
- 32-bit or half precision real and 64-bit or single precision real.
- The specific names for single precision real data provide a link to
- the 64-bit intrinsic functions. To ensure a link to the 32-bit
- intrinsic functions, use the generic function names with 32-bit real
- arguments. For example, use LLOOGG for any of the types of real data.
- Use AALLOOGG for single precision real arguments. Extended precision
- routines of math library routines are not provided on UNICOS/mk
- systems and only some routines have vector versions.
-
- UNICOS/mk systems have an additional library named lliibbmmffaassttvv. It
- contains versions of selected math intrinsics which can be faster than
- those in the default Math library. These alternate versions are not
- as accurate as the default library, and in some cases there are
- argument restrictions, such as not allowing the use of the --OO option
- on the compiler command line, or not allowing the use of infinities.
- These alternate versions are generally faster for loops with 50 or
- more iterations. To use lliibbmmffaassttvv, use the --ll mmffaassttvv option on the
- compiler's command line to load the library file. You must compile
- your code with the --OO33 or --OOvveeccttoorr33 option for the Fortran compiler or
- use --hh vveeccttoorr33 with the C compiler.
-
- For information on inlining and vectorization of the Fortran 90
- intrinsic procedures, see IINNTTRROO__IINNTTRRIINN(3I).
-
- The documentation for some of the most often used math library
- routines also contains information on Cray Assembly Language (CAL)
- register usage.
-
- For more information on calling library routines from various
- programming languages, see the subsection on this man page titled
- "Calling Functions from Fortran, C, or CAL."
-
- The math routines can be divided into the following general
- categories:
-
- * General arithmetic functions - In the routine descriptions, complex
- arguments are represented as
-
- _x = _x + _i_x .
- _r _i
- The real part of the complex number is _x ; _x is the imaginary part.
- _r _i
- Arguments and results are of the same type unless otherwise
- indicated.
-
- Base values raised to a power and 64-bit integer division are called
- implicitly from Fortran.
-
- * Exponential and logarithmic functions - The Cray Resesarch
- exponential and logarithmic functions are similar to the ANSI
- standard functions. Each function has variations for real, double
- precision, and complex values except the common logarithm function,
- which addresses only real and double-precision values. Complex
- arguments are represented as
-
- _x = _x + _i_x .
- _r _i
- _x is the real part of the complex number; _x is the imaginary part.
- _r _i
- * Trigonometric functions - The trigonometric functions are based on
- the ANSI standard for Fortran, except for the cotangent function and
- the CCOOSSSS (cosine and sine) function, which are Cray Research
- extensions.
-
- * Type conversion functions - Type conversion functions change the
- type of an argument. In the routine description, complex arguments
- are represented as
-
- _x = _x + _i_x .
- _r _i
- _x is the real part of the complex number; _x is the imaginary part.
- _r _i
- Arguments and results are of the same type, unless indicated
- otherwise.
-
- * Special functions - The special functions provide Fortran access to
- a number of Standard C functions on UNICOS/mk and UNICOS systems.
-
- * Extended-precision routines - The extended-precision routines
- perform double- and triple-precision arithmetic on UNICOS systems.
-
- * Boolean functions - The Boolean functions perform logical operations
- and bit manipulations. On UNICOS systems, the scalar subprograms
- are external versions of Fortran inline functions. They are all
- called by address; results are returned in register S1. All Boolean
- functions are extensions. These functions cannot be passed as
- arguments with CF90 on any system.
-
- CCaalllliinngg FFuunnccttiioonnss ffrroomm FFoorrttrraann,, CC,, oorr CCAALL
- Because of differences in the calling sequences for these languages,
- and other language differences, important variations must be noted in
- what functions can be called and how they are called.
-
- CCaalllliinngg ffrroomm FFoorrttrraann pprrooggrraammss
- Some function names are in uppercase, and some are in lowercase. The
- Fortran language is case-insensitive; the Cray Research Fortran
- compilers map all code in uppercase. This means that functions with
- lowercase names cannot be called from Fortran programs.
-
- CCaalllliinngg ffrroomm CC pprrooggrraammss
- The C language is case-sensitive. You must use the exact case
- specified in the documentation when coding references to a function.
-
- All functions documented in this manual are callable from C programs.
- The following rules can be used:
-
- * Because the function is not declared in a Standard C header,
- explicitly declare the function as external, and specify the type of
- the return value.
-
- * When calling the function, pass the address of the arguments by
- using the address operator (&) for each argument or by using a
- pointer to the argument. Array names are considered to be
- addresses; the address operator is not needed when using them.
-
- * The value returned by the function is the value, rather than the
- address of the value.
-
- * Specify the ffoorrttrraann keyword. The ffoorrttrraann keyword is an extension to
- the C language and is useful when a C program calls a function
- following the Cray Fortran calling sequence. Specifying the ffoorrttrraann
- keyword causes the C compiler to verify that the arguments used in
- each call to the function are pass-by-address.
-
- CCaalllliinngg ffrroomm CCrraayy AAsssseemmbbllyy LLaanngguuaaggee ((CCAALL))
- External references from Cray Assembly Language (CAL) are case-
- sensitive, so you must use the exact name for functions as specified
- on the man pages. Two standard calling methods are supported by Cray
- for math functions: call-by-register and call-by-address. For more
- information on the details of calling sequences, see the documentation
- for the CCAALLLL macro in _U_N_I_C_O_S _M_a_c_r_o_s _a_n_d _O_p_d_e_f_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l,
- publication SR-2403.
-
- It is strongly recommended that function linkage be done using the
- CCAALLLL macros. Direct user calls to functions by using the return-jump
- instruction should be avoided.
-
- Scalar functions return the result in registers S1 (and S2 if needed);
- results for complex double precision are returned in S1 through S4.
- Vector functions return their result in registers V1 (and V2 if
- needed); complex double precision are returned in V1 through V4. The
- number of elements computed for vector functions is determined by the
- contents of the vector-length register (VL) upon entry.
-
- For example, to call the SSQQRRTT routine using the call-by-address
- sequence, let _a_r_g_1 be the address of the argument.
-
- CAL usage:
-
- EEXXTT SSQQRRTT Declare the name to be an external
- CCAALLLL SSQQRRTT,,((_a_r_g_1) Call the function
- (result)S1 The result is returned in register S1 and
- stored at the address result
-
- Note that the name SSQQRRTT must be uppercase.
-
- To call the SSQQRRTT routine by using the call-by-register convention:
-
- (S1) Value of the argument
-
- CAL usage:
-
- EEXXTT SSQQRRTT%% Declare the name to be an external
- CCAALLLLVV SSQQRRTT%% Call the function
- (result)S1 The result is returned in register S1 and
- stored at the address result
-
- To call the routine for vector SSQQRRTT using the call-by-register
- convention, let V1 be the value of the vector argument and VL be the
- vector length (between 1 and 64 values will be returned).
-
- CAL usage:
-
- EEXXTT %%SSQQRRTT%% Declare the name to be an
- external
- CCAALLLLVV %%SSQQRRTT%% Call the function
-
- The result is returned in register V1. The vector-length register VL
- is unchanged.
-
- NNaammiinngg ccoonnvveennttiioonnss
- Most of the UNICOS math library functions adhere to the following
- naming convention:
-
- NNAAMMEE Entry for call-by-address
-
- NNAAMMEE%% Entry for scalar call-by-register
-
- %%NNAAMMEE%% Entry for vector call-by-register
-
- Note that assembly language does not support generic function names or
- automatic data type conversion. For example, there is no math library
- LLOOGG function for the logarithm routine. You must specify either AALLOOGG,
- DDLLOOGG, or CCLLOOGG for real, double-precision, or complex logarithm
- respectively, and the argument must be of the correct type (real,
- double-precision, or complex).
-
- RReeggiisstteerr ccoonnvveennttiioonnss
- The documentation for some of the widely used user-callable functions
- contains the register usage convention for the function. By default
- all the Cray Fortran compilers use the call-by-register convention for
- math library functions (it is the fastest calling sequence), and will
- put the %% prefix or suffix on the function name where needed. If a
- math library function is declared EEXXTTEERRNNAALL or IINNTTRRIINNSSIICC, the compilers
- will generate code for the call-by-address method.
-
- SSEEEE AALLSSOO
- IINNTTRROO__IINNTTRRIINN(3I)
-
- _C_r_a_y _S_t_a_n_d_a_r_d _C _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2074
-
- _C_F_9_0 _C_o_m_m_a_n_d_s _a_n_d _D_i_r_e_c_t_i_v_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-3901
-
- _F_o_r_t_r_a_n _L_a_n_g_u_a_g_e _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, _V_o_l_u_m_e _1, publication SR-3902
-
- _F_o_r_t_r_a_n _L_a_n_g_u_a_g_e _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, _V_o_l_u_m_e _2, publication SR-3903
-
- _F_o_r_t_r_a_n _L_a_n_g_u_a_g_e _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, _V_o_l_u_m_e _3, publication SR-3905
-
- _I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
-